// CachedImages
package main

import (
	"log"
)

type CachedImages []*Cacheitem

func (h *CachedImages) Push(elem interface{}) {
	log.Println("HEAP: Pushing", elem.(*Cacheitem).name)
	*h = append(*h, elem.(*Cacheitem))
}

func (h *CachedImages) Pop() interface{} {
	p := *h
	ret := p[len(p)-1]
	p[len(p)-1] = nil
	p = p[:len(p)-1]
	return ret
}

func (h CachedImages) Len() int {
	return len(h)
}

func (h CachedImages) Less(i, j int) bool {
	return h[i].score > h[j].score
}

func (h CachedImages) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}
